home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / circuits / spice2g6.z / spice2g6 / spice / Fortran / shlsrt.f < prev    next >
Encoding:
Text File  |  1989-02-03  |  675 b   |  38 lines

  1.       subroutine shlsrt(a,n)
  2.       implicit double precision (a-h,o-z)
  3. c
  4. c     this routine sorts the array a using a shell sort algorithm.
  5. c
  6.       dimension a(n)
  7.       integer h
  8. c
  9. c
  10. c...  compute best starting step size
  11.       h=1
  12.    10 h=3*h+1
  13.       if (h.lt.n) go to 10
  14. c...  back off two times
  15.       h=(h-1)/3
  16.       h=(h-1)/3
  17.       h=max0(h,1)
  18. c
  19. c  shell sort
  20. c
  21.    20 j=h+1
  22.       go to 60
  23.    30 i=j-h
  24. c...  ak = record key;  ar = record
  25.       ak=a(j)
  26.       ar=ak
  27.    40 if (ak.ge.a(i)) go to 50
  28.       a(i+h)=a(i)
  29.       i=i-h
  30.       if (i.ge.1) go to 40
  31.    50 a(i+h)=ar
  32.       j=j+1
  33.    60 if (j.le.n) go to 30
  34.       h=(h-1)/3
  35.       if (h.ne.0) go to 20
  36.       return
  37.       end
  38.